|
|
|
|
|
|
|
(table continued from previous page) |
|
|
|
|
| Object | Description | Method/Properties | | | Height/Width returns the height or width in twips of the screen area | | | TwipsPerPixelX/ TwipsPerPixelY returns the number of possible horizontal or vertical twips | | | MousePointer sets or returns the shape of the mouse cursor |
|
|
|
|
|
|
If you have worked with Visual Basic for any length of time, you might have seen some of these objects in use. For example, when using the MSGBOX statement to display a message to the user, you would want the caption to reflect the title of the application. To do this, you could enter the application title as a string every time you use a MSGBOX, or you can use the APP system object with its associated properties. The MSGBOX statement would resemble the following line of code: |
|
|
|
|
|
|
|
|
MSGBOX Incorrect Date entered. Try Again!, VBCritical, APP.Title |
|
|
|
|
|
|
|
|
You can do many different things using these objects. If you want to ensure that only one instance of your application executes at a time, you could use the PrevInstance property of the APP object as follows: |
|
|
|
|
|
|
|
|
If APP.Previnstance Then
MSGBOX Application is already running!, VBInformation, APP.Title
End
End If |
|
|
|
|
|
|
|
|
As you can see, the APP object provides runtime information about the current application. The Clipboard object gives you a way to provide users of your application with the standard Windows copy-and-paste functionality. If you decide to include the Edit, Copy and Edit, Paste menu options, then the Clipboard object would be used to provide that actual function. To see how this works, open the dlgFileOpenCopy project that you created on an earlier day. To this project, add a menu with only two main options, Copy and Paste. Then, add the following code to the form: |
|
|
|
|
|
|
|
|
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText txtSourceFile.Text
End Sub
Private Sub mnuPaste_Click()
txtTargetFile.Text = Clipboard.GetText()
End Sub |
|
|
|
|
|
|
|
|
When you run this application, you can copy text from the Source text box and then paste it into the Target text box. Of course, in this example, the object that is being |
|
|
|
|
|